<%-------------------------------------------------------------------
 * 页面名称：batchPay_1.jsp
 * 功能描述：批量支付
 * Action: 
 *
 *-------------------------------------------------------------------
--%>
<%@ page contentType="text/html; charset=utf-8"%>
<%@ taglib uri="/WEB-INF/conf/tld/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/conf/tld/struts-tiles.tld" prefix="tiles"%>
<%@ taglib uri="/WEB-INF/conf/tld/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/conf/tld/struts-bean.tld" prefix="bean"%>
<%@ taglib prefix="ad" uri="agiledata"%>
<%
String path = request.getContextPath();
%>
<link href="<%=path%>/css/style.css" rel="stylesheet" type="text/css" />
<link href="<%=path%>/css/newstyle.css" rel="stylesheet" type="text/css" />
<link href="<%=path%>/css/common.css" rel="stylesheet" type="text/css" />
<script type='text/javascript' src='<%=path%>/dwr/util.js'></script>
<script type='text/javascript' src='<%=path%>/dwr/engine.js'></script>
<script type='text/javascript'
	src='<%=path%>/dwr/interface/transactionFacade.js'></script>
<script type='text/javascript'
	src='<%=path%>/dwr/interface/accountTemplate.js'></script>
<script language="JavaScript" type="text/JavaScript">
var peerAccountType = "";
<logic:present name="batchPeerAccount">
<logic:equal name="batchPeerAccount" property="innerBatchPeerAccount" value="true">peerAccountType="inner";</logic:equal>
<logic:equal name="batchPeerAccount" property="bankBatchPeerAccount" value="true">peerAccountType="bank";</logic:equal>
</logic:present>
function submitProcess(){
	if(document.forms[0].remark.value.length>85){
		alert("备注长度不能大于85！");
		return;
	}
	var peerAccountCount = parseInt(document.getElementById("count").innerText);
	if(peerAccountCount<=0){
		alert("您还未设置交易对方账户和金额！");
		return;
	}
	if(checkNecessaryInput(document.forms[0])){
		document.forms[0].submit();
	}
}
function peerAccountSelect(){
 	agiledata.getUserInternal(peerAccountPopup);
}
function peerAccountPopup(data){
  	if(data) {
  		var options = document.forms[0].subAccountId.options;
  		var subAccountId = undefined;
  		for(var i=0;i<options.length;i++){
  			if(options[i].selected){
  				subAccountId = options[i].value;
  			}
  		}
        if(subAccountId!=undefined && subAccountId!=""){
            openLayer("<%=path%>/page/transaction/inputBatchPeerAccount.do?subAccountId="+subAccountId+"&type="+peerAccountType);
        }
	} else {
		location.href="<%=path%>/page/util/session_invalid.jsp";
	}
}
</script>
<div id="main">
	<div class="content_right">
		<div style="width:745px;margin-left:10px;">
			<div class="titleinfo">
				批量支付
			</div>
			<div class="edit_pass">
			<table width="100%" border="0" align="center" cellpadding="7"
										cellspacing="1" bgcolor="#f9e277" style="margin:10px 0;">
										<tr>
											<td bgcolor="#fffdf5">
												<table width="100%" border="0" cellpadding="3"
													cellspacing="0">
													<tr>
														<td width="3%" height="25" valign="top"
															style="border-bottom:1px solid #ccc;"></td>
														<td width="97%" align="left" class="red12b"
															style="border-bottom:1px solid #ccc;">
															特别提醒
														</td>
													</tr>
								<tr>
									<td valign="top">
										&nbsp;
									</td>
									<td align="left">
										您可以使用您的支付账户，
										<font color="red">同时选择多个对方账户并设置金额</font>进行批量支付！
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
				<html:form action="batchPay" method="post">
					<html:hidden property="step" />
					<table width="100%" border="0" align="center" cellpadding="5"
						cellspacing="1">
						<tr>
							<td width="23%" align="right" bgcolor="#FFFFFF" height="30px;">
								付款子账户：
							</td>
							<td width="77%" bgcolor="#FFFFFF" height="30px;">
								<div class="select">
									<div>
										<html:select property="subAccountId">
											<html:options collection="subAccounts" property="id"
												labelProperty="accountName" />
										</html:select>
									</div>
								</div>
							</td>
						</tr>
						<tr>
							<td align="right" height="30px;">
								<span class="orang12b">*</span> 收款方账户汇总：
							</td>
							<td bgcolor="#FFFFFF" height="30px;">
								<logic:present name="batchPeerAccount">
			共 <strong><span id="count" style="color:#FF0000;"><bean:write
												name="batchPeerAccount" property="count" /> </span> </strong> 笔
			<span id="type"><logic:equal name="batchPeerAccount"
											property="innerBatchPeerAccount" value="true">支付账户</logic:equal>
										<logic:equal name="batchPeerAccount"
											property="bankBatchPeerAccount" value="true">银行账户</logic:equal>
									</span>
			，总计 <strong><span id="total" style="color:#FF0000;"><ad:FormatPrase>
												<bean:write name="batchPeerAccount"
													property="totalAmountWithFee" />
											</ad:FormatPrase> </span> </strong> 元
		   </logic:present>
								<logic:notPresent name="batchPeerAccount">
			 共 <strong><span id="count" style="color:#FF0000;">0</span>
									</strong> 笔
			 <span id="type"></span>
			 ，总计 <strong><span id="total" style="color:#FF0000;">0.00</span>
									</strong> 元
		   </logic:notPresent>
								&nbsp;&nbsp;
								<img src="<%=path%>/images/icon_email.gif" width="13"
									height="10" border="0" style="cursor:hand"
									title="请点击此按钮，选择交易对方并设置金额" onclick="peerAccountSelect();" />
							</td>
						</tr>
						<tr>
							<td align="right" height="30px;">
								<span class="orang12b">*</span> 资金用途：
							</td>
							<td bgcolor="#FFFFFF" height="30px;">
								<html:text property="purpose" alt="资金用途" size="50"
									maxlength="85" styleClass="inputStyle" onblur="killSpace(this)" />
								(最长85个字符)
							</td>
						</tr>
						<tr>
							<td align="right" height="30px;">
								备注：
							</td>
							<td bgcolor="#FFFFFF">
								<html:textarea property="remark" rows="5" cols="35"
									style="border:1px solid #ccc;" />
								(最长85个字符)
							</td>
						</tr>
						<tr>
							<td height="25" align="center">
								&nbsp;
								<font color="#FF0000"><html:errors /> </font>
							</td>
						</tr>
						<tr>
							<td align="center">
								&nbsp;
							</td>
							<td bgcolor="#FFFFFF">
								<input name="button2" type="button" class="button_style"
									onclick="submitProcess();" value="下一步" />
							</td>
						</tr>
					</table>
				</html:form>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript" src="<%=path%>/js/layer.js"></script>
<script language="JavaScript" type="text/JavaScript">
function closeLayer(batchPeerAccount,type){
	hideLayer();
	var peerAccountCount = batchPeerAccount.count;
	if(peerAccountCount>0){
		if(type=="inner"){
			document.getElementById("type").innerText = "支付账户";
		}else{
			document.getElementById("type").innerText = "银行账户";
		}
		peerAccountType = type;
	}else{
		document.getElementById("type").innerText = "";
		peerAccountType = "";
	}
	document.getElementById("count").innerText = peerAccountCount;
	document.getElementById("total").innerText = peerAccountCount<=0 ? "0.00": formatAmount(batchPeerAccount.totalAmountWithFee);
}
</script>
